# CMakeList.txt: 顶层 CMake 项目文件，在此处执行全局配置
# 并包含子项目。
#
cmake_minimum_required (VERSION 3.8)

project (MyProjects)

set(CMAKE_CXX_STANDARD 11)

option(IS_WINDOWS OFF)
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
	set(IS_WINDOWS ON)
endif()

set(WORKSPACE_PATH ${PROJECT_SOURCE_DIR}/workspace)

# 寻找三方依赖
if(IS_WINDOWS)
    message(STATUS "Configuring on/for Windows")
	#message(FATAL_ERROR "Configuring on/for Windows")
	add_definitions(-D_WINDOWS)

# 寻找PCL依赖
	# 将PCL_ROOT环境变量中的"\"转为"/"，将转换后的值存入CMake变量
	file(TO_CMAKE_PATH $ENV{PCL_ROOT} PCL_ROOT) 
	# 将${PCL_ROOT}加入CMake的模块查找路径
	list(APPEND CMAKE_PREFIX_PATH ${PCL_ROOT}) 

	find_package(PCL REQUIRED)

	if (DEFINED PCL_INCLUDE_DIRS)
	message(INFO ${PCL_INCLUDE_DIRS})
	else()
	#set(PCL_INCLUDE_DIRS ${PCL_ROOT})
	message(WARNING ${PCL_INCLUDE_DIRS})
	endif()

	if(DEFINED PCL_LIBRARY_DIRS)
	message(INFO ${PCL_LIBRARY_DIRS})
	else()
	#set(PCL_LIBRARY_DIRS ${PCL_ROOT}/lib64-msvc-14.2)
	message(WARNING ${PCL_LIBRARY_DIRS})
	endif()

	file(GLOB PCL_LIBRARY_DIRS ${PCL_LIBRARY_DIRS}/*d.lib)

#添加Eigen头文件
	set(EIGEN_INCLUDE_DIRS $ENV{PCL_ROOT}/3rdParty/Eigen/eigen3)

# 寻找flann依赖 pcl的kdtree模块需要依赖这个库
	# Windows的pcl已经将flann集成到 3rdParty这个文件夹里了
	set(FLANN_INCLUDE_DIRS $ENV{PCL_ROOT}/3rdParty/FLANN/include)
	set(FLANN_LIBRARY_DIRS $ENV{PCL_ROOT}/3rdParty/FLANN/lib)

	file(GLOB FLANN_LIBRARIES ${FLANN_LIBRARY_DIRS}/*-gd.lib)

# 寻找vtk依赖 pcl的可视化模块需要依赖这个库
	# Windows的pcl已经将vtk集成到 3rdParty这个文件夹里了
	set(VTK_INCLUDE_DIRS $ENV{PCL_ROOT}/3rdParty/VTK/include)
	set(VTK_LIBRARY_DIRS $ENV{PCL_ROOT}/3rdParty/VTK/lib)

	file(GLOB VTK_LIBRARIES ${VTK_LIBRARY_DIRS}/*-gd.lib)

# 寻找opencv依赖
	# 将OPENCV_ROOT环境变量中的"\"转为"/"，将转换后的值存入CMake变量
	file(TO_CMAKE_PATH $ENV{OPENCV_ROOT} OPENCV_ROOT) 
	# 将${OPENCV_ROOT}加入CMake的模块查找路径
	list(APPEND CMAKE_PREFIX_PATH ${OPENCV_ROOT}) 

	find_package(Opencv REQUIRED)

	if (DEFINED OpenCV_INCLUDE_DIRS)
	message(INFO ${OpenCV_INCLUDE_DIRS})
	else()
	message(WARNING ${OpenCV_INCLUDE_DIRS})
	endif()

	if(DEFINED OpenCV_LIBRARY_DIRS)
	message(INFO ${OpenCV_LIBRARY_DIRS})
	else()
	message(WARNING ${OpenCV_LIBRARY_DIRS})
	endif()

# 寻找boost依赖
	# 将BOOST_ROOT环境变量中的"\"转为"/"，将转换后的值存入CMake变量
	file(TO_CMAKE_PATH $ENV{BOOST_ROOT} BOOST_ROOT) 
	# 将${BOOST_ROOT}加入CMake的模块查找路径
	list(APPEND CMAKE_PREFIX_PATH ${BOOST_ROOT}) 

	find_package(Boost REQUIRED)

	if (DEFINED BOOST_INCLUDE_DIRS)
	message(INFO ${BOOST_INCLUDE_DIRS})
	else()
	set(BOOST_INCLUDE_DIRS ${BOOST_ROOT})
	message(WARNING ${BOOST_INCLUDE_DIRS}/boost)
	endif()

	if(DEFINED BOOST_LIBRARY_DIRS)
	message(INFO ${BOOST_LIBRARY_DIRS})
	else()
	set(BOOST_LIBRARY_DIRS ${BOOST_ROOT}/lib64-msvc-14.2)
	message(WARNING ${BOOST_LIBRARY_DIRS})
	endif()

	file(GLOB BOOST_LIBRARIES ${BOOST_LIBRARY_DIRS}/*vc142-mt-gd-x64-1_74.lib)

else()
	# 假设是Linux
# 寻找PCL依赖
	find_package(PCL REQUIRED)
	
	if (DEFINED PCL_INCLUDE_DIRS)
	message(INFO ${PCL_INCLUDE_DIRS})
	else()
	#set(PCL_INCLUDE_DIRS "/usr/include/")
	message(WARNING "PCL_INCLUDE_DIRS has not been defined.")
	endif()

	if(DEFINED PCL_LIBRARY_DIRS)
	message(INFO ${PCL_LIBRARY_DIRS})
	else()
	#set(PCL_LIBRARY_DIRS "/usr/lib//x86_64-linux-gnu")
	message(WARNING ${PCL_LIBRARY_DIRS})
	endif()

	#file(GLOB BOOST_LIBRARIES ${PCL_LIBRARY_DIRS}/libboost*.so*)

# 寻找opencv以来
	find_package(OpenCV REQUIRED)

	if (DEFINED OpenCV_INCLUDE_DIRS)
	message(INFO ${OpenCV_INCLUDE_DIRS})
	else()
	#set(PCL_INCLUDE_DIRS ${PCL_ROOT})
	message(WARNING ${OpenCV_INCLUDE_DIRS})
	endif()

	if(DEFINED OpenCV_LIBRARY_DIRS)
	message(INFO ${OpenCV_LIBRARY_DIRS})
	else()
	#set(PCL_LIBRARY_DIRS ${PCL_ROOT}/lib64-msvc-14.2)
	message(WARNING ${OpenCV_LIBRARY_DIRS})
	endif()

# 寻找boost依赖
	find_package(Boost REQUIRED)
	
	if (DEFINED BOOST_INCLUDE_DIRS)
	message(INFO ${BOOST_INCLUDE_DIRS})
	else()
	set(BOOST_INCLUDE_DIRS "/usr/include/")
	message(WARNING ${BOOST_INCLUDE_DIRS}/boost)
	endif()

	if(DEFINED BOOST_LIBRARY_DIRS)
	message(INFO ${BOOST_LIBRARY_DIRS})
	else()
	set(BOOST_LIBRARY_DIRS "/usr/lib//x86_64-linux-gnu")
	message(WARNING ${BOOST_LIBRARY_DIRS})
	endif()

	file(GLOB BOOST_LIBRARIES ${BOOST_LIBRARY_DIRS}/libboost*.so*)
endif()

# 添加MYSDK依赖
file(TO_CMAKE_PATH $ENV{MYSDK_ROOT} MYSDK_ROOT) 
list(APPEND CMAKE_PREFIX_PATH ${MYSDK_ROOT}) 

set(MYSDK_INCLUDE_DIRS ${MYSDK_ROOT}/include)
set(MYSDK_LIBRARY_DIRS ${MYSDK_ROOT}/lib)

if (IS_WINDOWS)
	file(GLOB MYSDK_LIBRARIES ${MYSDK_LIBRARY_DIRS}/*.lib)
else()
	file(GLOB MYSDK_LIBRARIES ${MYSDK_LIBRARY_DIRS}/*.so)
endif()
set(SPDLOG_ROOT ${MYSDK_ROOT}/3rdParty/spdlog-1.9.2)


add_subdirectory("Demo01")
add_subdirectory("Demo02")
